#include <stdio.h>
#include <string.h>
#include "sm31.h"
const char* testCases[] = {
    "ljc",
    "20221302ljc",
};

int main() {

    // 调用自检函数并输出结果
    int selfTestResult = SM3_SelfTest();
    if (selfTestResult == 0) {
        printf("SM3 SelfTest passed.\n");
    }
    else {
        printf("SM3 SelfTest failed.\n");
    }

    // 计算并输出每个测试用例的哈希值
    for (int i = 0; i < sizeof(testCases) / sizeof(testCases[0]); i++) {
        unsigned char MsgHash[32] = { 0 };
        const char* testCase = testCases[i];
        int len = strlen(testCase);

        // 计算哈希值
        SM3_256((unsigned char*)testCase, len, MsgHash);

        // 打印计算出的哈希值
        printf("Computed Hash for '%s': ", testCase);
        for (int j = 0; j < 32; j++) {
            printf("%02x", MsgHash[j]);
        }
        printf("\n");
    }

    return 0;
}
